<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "product_branch".
 *
 * @property integer $id_product_branch
 * @property integer $id_product
 * @property integer $id_branch
 * @property string $quantity
 * @property string $updated
 * @property string $created
 *
 * @property Branch $idBranch
 * @property Product $idProduct
 */
class ProductBranch extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'product_branch';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['id_product', 'id_branch'], 'integer'],
            [['quantity'], 'number'],
            [['updated', 'created'], 'safe']
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id_product_branch' => 'Id Product Branch',
            'id_product' => 'Id Product',
            'id_branch' => 'Id Branch',
            'quantity' => 'Quantity',
            'updated' => 'Updated',
            'created' => 'Created',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getIdBranch()
    {
        return $this->hasOne(Branch::className(), ['id_branch' => 'id_branch']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getIdProduct()
    {
        return $this->hasOne(Product::className(), ['id_product' => 'id_product']);
    }
}
